<template>
  <div class="flex">
    <el-select
      v-model="formData.provinceObj"
      value-key="id"
      placeholder="请选择省份"
      clearable
      @change="provinceChange"
    >
      <el-option
        v-for="item in dProvinces"
        :key="item.id"
        :label="item.areaName"
        :value="{ id: item.id, name: item.areaName }"
      />
    </el-select>
    <el-select
      v-model="formData.cityObj"
      value-key="id"
      placeholder="请选择城市"
      clearable
      @change="cityChange"
    >
      <el-option
        v-for="item in dCitys"
        :key="item.id"
        :label="item.areaName"
        :value="{ id: item.id, name: item.areaName }"
      ></el-option>
    </el-select>
    <el-select
      v-model="formData.countyObj"
      value-key="id"
      placeholder="请选择区县"
      clearable
      @change="countyChange"
    >
      <el-option
        v-for="item in dCountys"
        :key="item.id"
        :label="item.areaName"
        :value="{ id: item.id, name: item.areaName }"
      ></el-option>
    </el-select>
  </div>
</template>

<script>
import cityMixins from './city-mixins'
export default {
  name: 'AreaSelect',
  components: {},
  props: {
    value: Object
  },
  mixins: [cityMixins],
  computed: {
    formData: {
      get() {
        return this.value
      },
      set(val) {
        this.$emit('input', val)
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.el-select {
  margin-right: 10px;
}
</style>
